<template>
        <Tree :data="baseData" show-checkbox :check-strictly="true" :check-directly="true" @on-check-change="treeChange"></Tree>
</template>
<script>
    import { postAction } from '@/api/request'
    export default {
        data () {
            return {
                baseData: [{
                    expand: false,
                    title: 'parent 1',
                    children: [{
                        title: 'parent 1-0',
                        expand: false,
                        // disabled: true,
                        children: [{
                            title: 'leaf',
                        }, {
                            title: 'leaf',
                        }]
                    }, {
                        title: 'parent 1-1',
                        expand: false,
                        checked: true,
                        children: [{
                            title: '<span style="color: red">leaf</span>',
                        }]
                    }]
                }]
            }
        },
        methods: {
                treeChange(arr, obj) {
                    //清空所有已选中的
                      arr.forEach(item => {
                         item.checked = false;
                      });
                      // 只选中最后一次选中的
                      obj.checked = true;
                      this.$emit("update:bindTextData",obj.title)
                      this.$emit("update:bindValueData", obj.value)
                }
        },
        mounted: function() {
        },
        watch:{

        },
        created () {
            //加载所有区划
            var that=this;
            var dataParam = {
                // level: this.level
            }
            postAction('/api/ac/subsistence/ss01001Service/xzqhTreeList', dataParam).then((res) => {
                that.baseData = res.data.data.data;
            }).finally(() => {
            })
        }
    }
</script>
